

import DefaultPlatform from "./DefaultPlatform";
import Platform = require('./Platform');
import WebAndroidPlatform from './WebAndroidPlatform';
import WebIOSPlatform from './WebIOSPlatform';
import WXGamePlatform from './WXGamePlatform';

export default class PlatformUtil {

    public static platform: Platform;

    public static init() {
        console.log(cc.sys.os)

        switch (cc.sys.platform) {
            case cc.sys.WECHAT_GAME:
            console.log("微信小游戏平台")
            this.platform =  new WXGamePlatform();
                break;
            case cc.sys.ANDROID:
            this.platform = new WebAndroidPlatform();
                break;
            case cc.sys.IPHONE:
            case cc.sys.IPAD:
            console.log("ios")
            this.platform = new WebIOSPlatform();
                break;
            default:
                if (cc.sys.isBrowser) {
            switch (cc.sys.os) {
                case cc.sys.OS_ANDROID:
                    this.platform = new WebAndroidPlatform();
                    break;
                case cc.sys.OS_IOS:
        
                    this.platform = new WebIOSPlatform();
                    break;
                default:
                    this.platform = new DefaultPlatform();
                    break;
            }

        } else {
            this.platform = new DefaultPlatform();
        }
                break;

            }

       
        window['platform'] = this.platform;

    }

}